﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace VTFC
{
    // ----------------------------------------------------------------------------
    /// <summary>
    /// New list/folder form.
    /// </summary>
    // ----------------------------------------------------------------------------
    public partial class FrmFolder : Form
    {
        // ----------------------------------------------------------------------------
        /// <summary>
        /// Constructor.
        /// </summary>
        // ----------------------------------------------------------------------------
        public FrmFolder()
        {
            InitializeComponent();
            InitializeContent();
        }//ctor

        private void InitializeContent()
        {
            this.Text = Resources.FrmFolder_Text;
            lblName.Text = Resources.FrmFolder_lblName;
            btnOk.Text = Resources.ButtonOk;
            btnCancel.Text = Resources.ButtonCancel;
        }//func InitializeContent

        // ----------------------------------------------------------------------------
        /// <summary>
        /// Name of the list/folder.
        /// </summary>
        // ----------------------------------------------------------------------------
        public string FolderName
        {
            get { return txtName.Text.Trim(); }
        }//prop FolderName

        private bool ValidateData()
        {
            bool valid = true;
            if (FolderName.Length == 0)
            {
                valid = false;
                BaseLogic.ShowError(Resources.Msg_Warrning_EmptyName);
            }
            return valid;
        }//func ValidateData

        private void Save()
        {
            if (ValidateData())
            {
                //ShowDialog used.
                this.DialogResult = DialogResult.OK;
            }
        }//func Save

        private void btnOk_Click(object sender, EventArgs e)
        {
            Save();
        }//func btnOk_Click

        private void txtName_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyData)
            {
                case Keys.Enter:
                    Save();
                    break;
                case Keys.Escape:
                    this.DialogResult = DialogResult.Cancel;
                    break;
            }
        }//func txtName_KeyDown
    }//class FrmNewList
}//namespace VTFC
